//
//  MainViewController.swift
//  SinaWeiBo
//
//  Created by RaysenLv on 16/6/6.
//  Copyright © 2016年 RaysenLv. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        addChildViewControllers()
        
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    private func addChildViewControllers () {
        
       addChildViewController(HomeTableViewController(),title: "首页",imageName: "tabbar_home")
         addChildViewController(MessageTableViewController(),title: "消息",imageName: "tabbar_message_center")
         addChildViewController(DiscoverTableViewController(),title: "发现",imageName: "tabbar_discover")
        
        addChildViewController(DiscoverTableViewController(),title: "我",imageName: "tabbar_profile")
    }
    
    private func addChildViewController(vc: UIViewController,title:String,imageName:String) {
       
        let nav=UINavigationController(rootViewController: vc )
        nav.title=title
        
        
        nav.tabBarItem.image=UIImage(named: imageName)
        self.tabBar.tintColor=UIColor.orangeColor()
//        nav.tabBarItem.selectedImage=UIImage(named: imageName+"_highlighted")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
//        nav.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: UIControlState.Selected)
        
        
        addChildViewController(nav)
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
